package org.lalib.mediator;

import java.util.List;

import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.lalib.acquire.IMediator;
import org.lalib.entity.object.EUser;
import org.lalib.foundation.FDataAccess;
import org.springframework.stereotype.Repository;

@Repository(value = "mUser")
public class MUser extends FDataAccess<EUser> implements IMediator {

	private static final long serialVersionUID = 1L;

	@Override
	protected Class<EUser> getClassType() {
		return EUser.class;
	}

	@SuppressWarnings("unchecked")
	public List<EUser> getUserListForGivenName(String name) {
		return (List<EUser>) getSession().createCriteria(EUser.class).add(Restrictions.ilike("name", name, MatchMode.ANYWHERE)).list();
	}

	@SuppressWarnings("unchecked")
	public List<EUser> getAllUsers() {
		return getSession().createCriteria(getClassType()).list();
	}
}